package ${location}.utils;

import org.springframework.util.DigestUtils;

import java.nio.charset.StandardCharsets;

/**
 * @author ${author}
 */
public class Md5Utils {
	public static <T> String convert(T object) {
		String result = null;
		if (object == null) {
			return null;
		}
		if (object instanceof String || object instanceof Number) {
			result = DigestUtils.md5DigestAsHex(object.toString().getBytes(StandardCharsets.UTF_8));
		}
		if (object instanceof byte[]) {
			result = convert(new String((byte[]) object, StandardCharsets.UTF_8));
		}
		return result;
	}
}
